<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="招标项目编号">
              <a-input placeholder="请输入招标项目编号" v-model="queryParam.tenderProjectCode"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="相关标段（包）编号">
              <a-input placeholder="请输入相关标段（包）编号" v-model="queryParam.bidSectionCodes"></a-input>
            </a-form-item>
          </a-col>
          <template v-if="toggleSearchStatus">
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="招标编号">
                <a-input placeholder="请输入招标编号" v-model="queryParam.tenderCode"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="公告标题">
                <a-input placeholder="请输入公告标题" v-model="queryParam.noticeName"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="状态">
                <j-dict-select-tag placeholder="请选择状态" v-model="queryParam.status" dictCode="sys_common_status" />
              </a-form-item>
            </a-col>
          </template>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        class="j-table-force-nowrap"
        :scroll="{ x: true }"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange"
      >
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text, record">
          <span v-if="!text" style="font-size: 12px; font-style: italic">无图片</span>
          <img
            v-else
            :src="getImgView(text)"
            :preview="record.id"
            height="25px"
            alt=""
            style="max-width: 80px; font-size: 12px; font-style: italic"
          />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span>
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <template v-if="record.status == 1">
            <a @click="goAudit(record.id)">审批</a>
            <a-divider type="vertical" />
          </template>
          <a @click="handleDetail(record)">详情</a>
        </span>
      </a-table>
    </div>

    <ex-tender-ann-qua-inquery-ann-modal ref="modalForm" @ok="modalFormOk" />
    <audit-modal ref="auditModal" @ok="doAudit"></audit-modal>
  </a-card>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import ExTenderAnnQuaInqueryAnnModal from './modules/ExTenderAnnQuaInqueryAnnModal'
import AuditModal from '@/views/exOperationRecord/AuditModal'
import { filterMultiDictText } from '@/components/dict/JDictSelectUtil'
import '@/assets/less/TableExpand.less'
import { httpAction } from '@/api/manage'

export default {
  name: 'ExTenderAnnQuaInqueryAnnList',
  mixins: [JeecgListMixin],
  components: {
    ExTenderAnnQuaInqueryAnnModal,
    AuditModal,
  },
  data() {
    return {
      description: '招标文件审核',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '招标项目编号',
          align: 'center',
          dataIndex: 'tenderProjectCode',
        },
        {
          title: '相关标段（包）编号',
          align: 'center',
          dataIndex: 'bidSectionCodes',
        },
        {
          title: '监督部门代码',
          align: 'center',
          dataIndex: 'superviseDeptCode',
        },
        {
          title: '招标编号',
          align: 'center',
          dataIndex: 'tenderCode',
        },
        {
          title: '公告标题',
          align: 'center',
          dataIndex: 'noticeName',
        },
        {
          title: '公告发布时间',
          align: 'center',
          dataIndex: 'noticeSendTime',
          customRender: function (text) {
            return !text ? '' : text.length > 10 ? text.substr(0, 10) : text
          },
        },
        {
          title: '公告截止时间',
          align: 'center',
          dataIndex: 'noticeEndTime',
          customRender: function (text) {
            return !text ? '' : text.length > 10 ? text.substr(0, 10) : text
          },
        },
        {
          title: '公告类型',
          align: 'center',
          dataIndex: 'bulletinType_dictText',
        },
        {
          title: '状态',
          align: 'center',
          dataIndex: 'status_dictText',
        },
        {
          title: '创建时间',
          align: 'center',
          dataIndex: 'createTime',
          customRender: function (text) {
            return !text ? '' : text.length > 10 ? text.substr(0, 10) : text
          },
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' },
        },
      ],
      url: {
        list: '/exTenderAnnQuaInqueryAnn/exTenderAnnQuaInqueryAnn/list',
        delete: '/exTenderAnnQuaInqueryAnn/exTenderAnnQuaInqueryAnn/delete',
        deleteBatch: '/exTenderAnnQuaInqueryAnn/exTenderAnnQuaInqueryAnn/deleteBatch',
        exportXlsUrl: '/exTenderAnnQuaInqueryAnn/exTenderAnnQuaInqueryAnn/exportXls',
        importExcelUrl: 'exTenderAnnQuaInqueryAnn/exTenderAnnQuaInqueryAnn/importExcel',
        audit: 'exTenderAnnQuaInqueryAnn/exTenderAnnQuaInqueryAnn/audit',
      },
      dictOptions: {},
      superFieldList: [],
      queryParam: {
        status: '1',
      },
      confirmLoading: false,
    }
  },
  created() {
    this.getSuperFieldList()
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    initDictConfig() {},
    getSuperFieldList() {
      let fieldList = []
      fieldList.push({ type: 'string', value: 'tenderProjectCode', text: '招标项目编号', dictCode: '' })
      fieldList.push({ type: 'string', value: 'bidSectionCodes', text: '相关标段（包）编号', dictCode: '' })
      fieldList.push({ type: 'string', value: 'unifiedDealCodes', text: '统一交易标识码', dictCode: '' })
      fieldList.push({ type: 'string', value: 'superviseDeptName', text: '监督部门名称', dictCode: '' })
      fieldList.push({ type: 'string', value: 'superviseDeptCode', text: '监督部门代码', dictCode: '' })
      fieldList.push({ type: 'string', value: 'tenderCode', text: '招标编号', dictCode: '' })
      fieldList.push({ type: 'string', value: 'noticeName', text: '公告标题', dictCode: '' })
      fieldList.push({ type: 'string', value: 'noticeContent', text: '公告内容', dictCode: '' })
      fieldList.push({ type: 'date', value: 'noticeSendTime', text: '公告发布时间' })
      fieldList.push({ type: 'string', value: 'noticeMedia', text: '公告发布媒体', dictCode: '' })
      fieldList.push({ type: 'string', value: 'url', text: '公告源url', dictCode: '' })
      fieldList.push({ type: 'string', value: 'noticeNature', text: '公告性质', dictCode: '' })
      fieldList.push({ type: 'string', value: 'bulletinType', text: '公告类型', dictCode: '' })
      fieldList.push({ type: 'date', value: 'docGetStartTime', text: '招标文件/资格预审文件获取时间' })
      fieldList.push({ type: 'date', value: 'docGetEndTime', text: '招标文件/资格预审文件获取截止时间' })
      fieldList.push({
        type: 'string',
        value: 'tenderDocGetMethod',
        text: '招标文件/资格预审文件获取方法',
        dictCode: '',
      })
      fieldList.push({ type: 'date', value: 'bidDocReferEndTime', text: '投标文件/资格预审申请文件递交截止时间' })
      fieldList.push({ type: 'date', value: 'bidOpenTime', text: '开标时间' })
      fieldList.push({ type: 'BigDecimal', value: 'docPrice', text: '文件售价', dictCode: '' })
      fieldList.push({ type: 'string', value: 'docPriceCurrency', text: '文件售价币种', dictCode: '' })
      fieldList.push({ type: 'string', value: 'docPriceUnit', text: '文件售价单位', dictCode: '' })
      fieldList.push({
        type: 'string',
        value: 'bidDocReferMethod',
        text: '投标文件/资格预审申请文件递交方法',
        dictCode: '',
      })
      fieldList.push({ type: 'string', value: 'syndicatedFlag', text: '是否允许联合体投标', dictCode: '' })
      fieldList.push({ type: 'string', value: 'isPostpone', text: '是否延期开标', dictCode: '' })
      fieldList.push({ type: 'string', value: 'bidOpenMethod', text: '开标方式/文件开启方式', dictCode: '' })
      fieldList.push({ type: 'string', value: 'qualType', text: '评审办法', dictCode: '' })
      fieldList.push({ type: 'string', value: 'tenderCodeType', text: '招标人代码类型', dictCode: '' })
      fieldList.push({ type: 'string', value: 'tendererCode', text: '招标人代码', dictCode: '' })
      fieldList.push({ type: 'string', value: 'tendererName', text: '招标人名称', dictCode: '' })
      fieldList.push({ type: 'string', value: 'tendererAddress', text: '招标人地址', dictCode: '' })
      fieldList.push({ type: 'string', value: 'tendererContactor', text: '招标人联系人', dictCode: '' })
      fieldList.push({ type: 'string', value: 'tendererPhoneNumber', text: '招标人联系电话', dictCode: '' })
      fieldList.push({ type: 'string', value: 'tendererEmail', text: '招标人电子邮箱', dictCode: '' })
      fieldList.push({ type: 'string', value: 'tenderAgencyCodeType', text: '招标代理机构代码类型', dictCode: '' })
      fieldList.push({ type: 'string', value: 'tenderAgencyCode', text: '招标代理机构代码', dictCode: '' })
      fieldList.push({ type: 'string', value: 'tenderAgencyName', text: '招标代理机构名称', dictCode: '' })
      fieldList.push({ type: 'string', value: 'tenderAgencyAddress', text: '招标代理机构地址', dictCode: '' })
      fieldList.push({ type: 'string', value: 'tenderAgencyContactor', text: '招标代理机构联系人', dictCode: '' })
      fieldList.push({ type: 'string', value: 'tenderAgencyPhoneNumber', text: '招标代理机构联系电话', dictCode: '' })
      fieldList.push({ type: 'string', value: 'tenderAgencyEmail', text: '招标代理机构电子邮箱', dictCode: '' })
      fieldList.push({ type: 'string', value: 'otherContent', text: '其他内容', dictCode: '' })
      fieldList.push({ type: 'string', value: 'bulletinDuty', text: '公告发布责任人', dictCode: '' })
      fieldList.push({ type: 'string', value: 'bulletinDutyCodeType', text: '交易平台验证责任人', dictCode: '' })
      fieldList.push({ type: 'string', value: 'attachmentCode', text: '附件关联标识号', dictCode: '' })
      fieldList.push({ type: 'string', value: 'platformCode', text: '交易系统标识码', dictCode: '' })
      fieldList.push({ type: 'date', value: 'noticeEndTime', text: '公告截止时间' })
      fieldList.push({ type: 'string', value: 'status', text: '状态', dictCode: 'sys_common_status' })
      fieldList.push({ type: 'date', value: 'createTime', text: '创建时间' })
      this.superFieldList = fieldList
    },
    doAudit(param) {
      var that = this
      that.confirmLoading = true
      httpAction(
        this.url.audit,
        { id: param.entryId, status: param.operateResult, operateOpinion: param.operateOpinion },
        'post',
      )
        .then((res) => {
          if (res.success) {
            that.$message.success(res.message)
            that.loadData()
          } else {
            that.$message.warning(res.message)
          }
        })
        .finally(() => {
          that.confirmLoading = false
        })
    },
    goAudit(id) {
      var that = this
      that.$refs.auditModal.show(id)
    },
    searchReset() {
      this.queryParam = { status: '1' }
      this.loadData()
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>